﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Fysh.ComputerScience.Genetics
{
    public class Node : ICloneable
    {
        public float LengthA
        {
            get
            {
                throw new System.NotImplementedException();
            }
            set
            {
            }
        }

        public float LengthB
        {
            get
            {
                throw new System.NotImplementedException();
            }
            set
            {
            }
        }

        public Node ChildA
        {
            get
            {
                throw new System.NotImplementedException();
            }
            set
            {
                if (value.GetType() == typeof(Sequence)) ;
            }
        }

        public Node ChildB
        {
            get
            {
                throw new System.NotImplementedException();
            }
            set
            {
            }
        }

        public Sequence CurrentNode
        {
            get
            {
                throw new System.NotImplementedException();
            }
            set
            {
            }
        }

        public int ChildrenCount
        {
            get
            {
                throw new System.NotImplementedException();
            }
            set
            {
            }
        }

        #region ICloneable Members

        public object Clone()
        {
            //create a new node
            Node currentNode = new Node();
            //recursively explore tree
            if (this.ChildA != null)
            {
                currentNode.ChildA = (Node)this.ChildA.Clone();
                currentNode.LengthA = this.LengthA;
                currentNode.ChildrenCount += currentNode.ChildA.ChildrenCount + 1;
            }
            if (this.ChildB != null)
            {
                currentNode.ChildB = (Node)this.ChildB.Clone();
                currentNode.LengthB = this.LengthB;
                currentNode.ChildrenCount += currentNode.ChildB.ChildrenCount + 1;
            }

            //get reference to sequence
            if (this.CurrentNode != null)
                currentNode.CurrentNode = this.CurrentNode;

            return currentNode;
        }

        #endregion
    }
}
